<template>
  <div
    class="page-template-default page page-id-4987 wp-embed-responsive
  exam-apo-two exam-style-radius nice-style-shadow nice-style-border
  lights-mode"
    style="background: #F6F6F7;"
  >
    <remote-css
      href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css"
    ></remote-css>
    <div class="exam-apo-sign d-flex flex-fill align-items-lg-center h-v ">
      <main class="exam-sign-main ">
        <div class="exam-sign-inner shadow-2x">
          <div class="row no-gutters">
            <div class="col-12 col-md-12 col-lg-6 col-xl-7 order-1">
              <div
                class="sign-cover d-flex flex-column bg-secondary bg-img bg-cover bg-dark w-100 h-100 p-4 p-md-5 p-lg-4"
                style="background-image: url(https://img.smitish.com/wp-content/uploads/20200922133511.png);"
              >
                <h1 class="smitish-sign-logo mx-auto mx-lg-2 my-auto my-lg-2">
                  <a title="Exam Cloud Pro" href="/" class="d-block"
                    ><img
                      src="https://img.smitish.com/wp-content/uploads/20201031110238.png"
                  /></a>
                </h1>
              </div>
            </div>
            <div class="col-12 col-md-12 col-lg-6 col-xl-5 order-2">
              <div class="sign-content bg-white mt-n4 mt-lg-0 mb-4 mb-lg-0">
                <a class="offiaccount-sign exam-sign-erweima"></a>
                <div class="sign-body">
                  <div
                    class="sign-header text-font h2 text-center mb-4 mb-md-5"
                    style="font-weight: 900;font-size: 2.2rem;"
                  >
                    欢迎回来！
                  </div>
                  <form
                    id="sign-form"
                    :model="ruleForm"
                    :rules="rules"
                    ref="ruleForm"
                    style="display: block;"
                  >
                    <div class="form-group" style="margin-top: 50px;">
                      <input
                        type="text"
                        class="form-control form-control-lg"
                        name="InputPhone"
                        id="InputPhone"
                        v-model="ruleForm.username"
                        style="font-size: 1.2rem;font-weight: 800;"
                        placeholder="用户名"
                      />
                    </div>

                    <div class="form-group">
                      <input
                        type="password"
                        class="form-control form-control-lg"
                        name="InputPassword1"
                        id="InputPassword1"
                        style="font-size: 1.2rem;font-weight: 800;"
                        v-model="ruleForm.password"
                        placeholder="密码"
                      />
                    </div>
                    <div class="form-aciton mt-4">
                      <button
                        type="button"
                        class="btn btn-primary btn-block "
                        @click="submitForm('ruleForm')"
                      >
                        <span style="font-size: 1.5rem;font-weight: 800;"
                          >登录</span
                        >
                      </button>
                    </div>
                  </form>
                  <div class="text-muted  text-sm text-center mt-5 mt-md-5 ">
                    <a class="register" @click="toRegister">立即注册</a>
                    <i class="text-muted exam-apo  mx-1"></i>
                    <span><a href="/">返回主页</a></span>
                  </div>
                  <div
                    class="pt-5 pt-md-5 ext-muted text-sm text-center"
                    style="padding-top: 40px;"
                  >
                    <!-- <span>Powered by © 2019-2020 SMITISH.COM</span> -->
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </main>
    </div>
  </div>
</template>

<script>
const key = "loginMessage";
export default {
  components: {
    "remote-css": {
      render(createElement) {
        return createElement("link", {
          attrs: { rel: "stylesheet", href: this.href }
        });
      },
      props: {
        href: { type: String, required: true }
      }
    }
  },
  name: "Login",
  data() {
    return {
      ruleForm: {
        username: "Smitish",
        password: "111111"
      },
      rules: {
        username: [
          { required: true, message: "请输入用户名", trigger: "blur" },
          { min: 3, max: 15, message: "长度在 3 到 15 个字符", trigger: "blur" }
        ],
        password: [{ required: true, message: "请输入密码", trigger: "change" }]
      }
    };
  },
  methods: {
    submitForm(formName) {
      this.$message.loading({ content: "Login...", key });
      const _this = this;
      // 发起请求
      this.$axios.post("/api/v1/login", this.ruleForm).then(res => {
        console.log(res);
        setTimeout(() => {
          //设置延迟执行
          // console.log(res.headers);
          if (res.data.code == 200) {
            const jwt = res.headers["authorization"];
            const userInfo = res.data.data;
            const role =
              res.data.role == 0 ? "de72303d2cb6ea86" : "4eb118447d8e3cf0";
            // 把数据共享出去
            _this.$store.commit("SET_TOKEN", jwt);
            _this.$store.commit("SET_USERINFO", userInfo);
            _this.$store.commit("SET_ROLE", role);
            // 获取
            console.log(_this.$store.getters.getUser);
            this.$message.success({ content: "登入成功!", key });
            _this.$router.push("/home");
          } else {
            this.$message.error({ content: res.data.msg, key });
          }
        }, 500);
      });
    },
    resetForm(formName) {
      this.$store.commit("REMOVE_INFO");
      this.$refs[formName].resetFields();
    },
    toRegister() {
      this.$router.push("/register");
    }
  }
};
</script>

<style scoped>
.h-v {
  min-height: 100vh;
}

.exam-sign-main {
  width: 100%;
  margin: 0 auto;
  position: relative;
}

.exam-sign-inner {
  position: relative;
  overflow: hidden;
  -webkit-box-shadow: 0px 0px 20px 0px rgba(158, 158, 158, 0.1);
  box-shadow: 0px 0px 20px 0px rgba(158, 158, 158, 0.1);
}

.exam-sign-logo {
  max-width: 160px;
}

.exam-sign-inner .sign-content {
  padding: 100px 80px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-box-flex: 1;
  -ms-flex: 1 1 auto;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
}

.exam-sign-inner .sign-body {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 auto;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}

.exam-sign-inner .sige-getpwd {
  margin: auto;
  -webkit-flex: none;
  -webkit-box-flex: 0;
  -ms-flex: none;
  flex: none;
}

@media (min-width: 1200px) {
  .exam-sign-main {
    max-width: 1140px;
    height: 100%;
  }

  .exam-sign-inner .sign-content {
    height: 66vh;
    max-height: 680px;
  }
}

@media (min-width: 992px) and (max-width: 1199.98px) {
  .exam-sign-main {
    max-width: 960px;
    height: 100%;
  }

  .exam-sign-inner .sign-content {
    padding: 100px 60px;
    height: 66vh;
    max-height: 580px;
  }
}

@media (max-width: 991.98px) {
  .exam-apo-sign .sign-cover {
    min-height: 33.333vh;
  }

  .exam-apo-sign .sign-content {
    position: relative;
    border-radius: 3px;
    -webkit-box-shadow: 0px 0px 35px 15px rgba(158, 158, 158, 0.25);
    box-shadow: 0px 0px 35px 15px rgba(158, 158, 158, 0.25);
  }

  .exam-sign-inner {
    background-color: #f6f6f7;
    border-radius: 0;
    -webkit-box-shadow: none;
    box-shadow: none;
    height: 100%;
  }

  .exam-sign-inner.rounded {
    border-radius: 0 !important;
  }

  .exam-sign-inner .sign-content {
    padding: 50px 40px;
    margin-left: 30px;
    margin-right: 30px;
  }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .exam-sign-inner .sign-content {
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (max-width: 767.98px) {
  .exam-apo-sign .sign-cover {
    min-height: 45vh;
  }

  .exam-sign-inner .sign-content {
    margin-left: 20px;
    margin-right: 20px;
    padding: 40px 20px;
  }
}

.lights-mode .shadow,
.lights-mode .shadow-2x {
  -webkit-box-shadow: none !important;
  box-shadow: none !important;
}

.exam-sign-inner {
  position: relative;
  overflow: hidden;
  -webkit-box-shadow: 0px 0px 20px 0px rgba(158, 158, 158, 0.1);
  box-shadow: 0px 0px 20px 0px rgba(158, 158, 158, 0.1);
}

.exam-apo-two .no-gutters > .col,
.exam-apo-two .no-gutters > [class*="col-"] {
  padding-left: 0;
  padding-right: 0;
}

.bg-cover {
  -ms-background-size: cover;
  background-size: cover;
  background-repeat: no-repeat;
}

.bg-img {
  background-size: cover;
  background-position: 50% 50%;
  background-repeat: no-repeat;
}

.exam-sign-logo {
  max-width: 160px;
}

.lights-mode,
.lights-mode a:not(.btn) {
  color: #999;
}

a:link,
a:visited {
  text-decoration: none;
}

a img {
  border: 0 none;
}

img {
  max-width: 100%;
  height: auto;
  position: relative;
}

.exam-sign-inner .sign-content {
  padding: 100px 80px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-box-flex: 1;
  -ms-flex: 1 1 auto;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
}

.lights-mode .bg-white {
  background-color: #21242b !important;
}

.lights-mode .exam-sign-erweima {
  background-image: url();
}

a:link,
a:visited {
  text-decoration: none;
}

.exam-sign-erweima {
  position: absolute;
  right: 5px;
  top: 5px;
  width: 45px;
  height: 45px;
  background-image: url();
  background-position: top center;
  background-repeat: no-repeat;
  background-size: contain;
}

a {
  color: #161e27;
  -webkit-transition: all 0.3s ease;
  -o-transition: all 0.3s ease;
  transition: all 0.3s ease;
  cursor: pointer;
}

.exam-sign-inner .sign-body {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 auto;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}

h2,
.h2 {
  font-size: 2.25rem;
  color: #21242b;
}

.h1,
.h2,
.h3,
.h4,
.h5,
.h6,
h1,
h2,
h3,
h4,
h5,
h6 {
  margin-bottom: 0;
  line-height: 1.5;
}

body,
input,
button,
select,
optgroup,
option,
textarea,
blockquote,
dd,
dl,
figure,
form,
pre,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6,
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: "SF Pro SC", "SF Pro Text", "SF Pro Icons", PingFang SC,
    Lantinghei SC, Microsoft Yahei, Hiragino Sans GB, Microsoft Sans Serif,
    WenQuanYi Micro Hei, sans-serif;
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
}

.lights-mode .btn-light {
  color: #969aa7;
  background-color: #2e313a;
  border-color: #2e313a;
}

.exam-style-radius .btn-circle {
  border-radius: 50%;
}

.exam-style-radius .nav-links > span,
.exam-style-radius .nav-links > a,
.exam-style-radius .btn,
.exam-style-radius .form-control {
  border-radius: 5px;
}

.btn-icon.btn-lg {
  width: 2.875rem;
  height: 2.875rem;
  font-size: 1.375rem;
}

.btn-icon span {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  display: -webkit-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
}

.exam-apo.text-lg {
  font-size: 1.5rem !important;
}

.exam-apo {
  line-height: 1;
  display: inline-block;
  vertical-align: middle;
}

.exam-apo {
  font-family: "exam-apo" !important;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  vertical-align: middle;
}

.lights-mode .form-control {
  /* border: 2px solid rgb(121, 167, 252); */

  border: none;
  border-bottom: 2px solid rgb(121, 167, 252);
  border-radius: 0;
  background-color: #fff !important;
  color: #333;
  -webkit-box-shadow: none;
  box-shadow: none;
}

.form-control-lg {
  font-size: 0.9375rem;
  line-height: 1.5;
  padding: 0.75rem 1rem;
  height: calc(1.5em + 1.625rem + 2px);
}

.lights-mode .text-muted {
  color: #969aa7 !important;
}

.exam-apo {
  line-height: 1;
  display: inline-block;
  vertical-align: middle;
}

.btn-group-lg > .btn,
.btn-lg {
  padding: 0.75rem 2.5rem;
  font-size: 1rem;
}

.lights-mode .bg-white {
  background-color: #fff !important;
}

.lights-mode .exam-time-main,
.lights-mode.exam-apo-two {
  background-color: #fafafa;
}

.exam-apo-two,
.exam-time-main,
.tax-weibo_topic {
  background-color: #f6f6f7;
}
.smitish-sign-logo {
  max-width: 260px;
}
.register::hover {
  color: #000;
}
</style>
